/*
 * lottery.c
 * 公证人程序
 * v2更新：结构体指针数组，数组中嵌入链表
 * v3更新：更新彩票信息，显示获奖人
 */

/*头文件*/
//------------------------------------
#include "lottery.h"
//------------------------------------

/*使用文件，文件指针*/
//------------------------------------
char* user_info="data/user_info.txt";
char* lottery_info="data/lottery_info.txt";
char* lottery_man="data/lottery_man.txt";
char* prize_pool="data/prize_pool.txt";
FILE* f_prize_pool;
FILE* f_lottery_man;
//------------------------------------

/*全局变量声明*/
//------------------------------------
int QIHAO, perPrice_lottery, STATE,\
			NEXT_AWARD_POOL,GREAT_AWARD,\
			MIDDLE_AWARD,SMALL_AWARD,PRIZE_POOL;
//------------------------------------


/*主函数*/
//------------------------------------
int main(int argc, char **argv)
{
	char sissue[LOTTERY_SIZE];
	xLottery plots;
	winner_list* winner_list_arr[3]; //对应5,4,3个注获奖者
	for(int i=0;i<3;++i) //初始化链表数组
	{
		winner_list_arr[i]=(winner_list*)calloc(1,sizeof(winner_list));
		winner_list_arr[i]->next=NULL;
	}
	
	init();
	
	menu();
	
	while(1){
	printf("请输入操作指令：");
	int choice; if(1!=scanf("%d",&choice))
	{while(getchar()!='\n');continue;}
	
	enum {_logout,_issue,_manual_issue, _show_winners, _issued, _notissued, _menu=11, _sysout=99};
	switch(choice)
	{
		case _logout: exit(0);
		break;
		case _sysout: exit(3);
		break;
		case _manual_issue: 
		issue(&plots,winner_list_arr,sissue,1);
		share(winner_list_arr,sissue);
		break;
		case _issue: 
		issue(&plots,winner_list_arr,sissue,0);
		share(winner_list_arr,sissue);
		break;
		case _show_winners: show_winners();
		break;
		case _issued: show_issued(1);
		break;
		case _notissued: show_issued(0);
		break;
		case _menu: menu();
		break;
		}
	}
	
	
	return 0;
}
